.386
.model	flat,c
includelib  2020\LIB\msvcrt.lib
includelib  2020\LIB\ucrt.lib
includelib  2020\LIB\legacy_stdio_definitions.lib
printf	PROTO C :dword, :vararg
scanf   PROTO C : dword, :dword,:vararg
public	F_ONE
public	F_TWO
PUBLIC	F_THREE
PUBLIC	F_FOUR
.DATA	
		CHECK	DB	"OK",0AH,0DH,0
		LEAD1	DB	"Please input your name",0AH,0DH,0
		LEAD2	DB	"Please input your password",0AH,0DH,0
		LEAD3	DB	"Fail to load",0AH,0DH,0
		LEAD4	DB	"Please input good name",0AH,0DH,0
		LEAD5	DB	"NOT  FIND!",0AH,0DH,0
		LEAD6	DB	"Success load",0AH,0DH,0
		LEAD7	DB	"Success find",0AH,0DH,0
		LEAD8	DB	"NO find",0AH,0DH,0
		LEAD9	DB	"Invalid browsing",0AH,0DH,0
		LEAD10	DB	"Successily buy",0AH,0DH,0
		LEAD11	DB	"Successily caculate",0AH,0DH,0
		format	DB	"%s",0
		BNAME	DB	"CHENKE",0
		BPASS	DB	"CHENKE",0
		CHEN	DB	2
		COUNT1  EQU	12
		COUNT2	EQU	4
		N	EQU	30 
		GA1	DB	"PEN",7 DUP(0),10
			DW	35,56,75,25,?  
		GA2	DB	"BOOK",6 DUP(0),9
			DW	12,30,20,5,?
		GOOD	DB      30 DUP(0)
		COUNTGA1	EQU	3
		COUNTGA2	EQU	4
		GAN	DB	N-2 DUP("TempValue",0,8,15,0,20,0,30,0,2,0,?,?)
		IN_NAME	DB	20,0,20 DUP(0)
		IN_PWD	DB	20,0,20 DUP(0)
		GOOD_NAME	DB	20,0,20 DUP(0)
 		AUTH	DB	0             
.CODE
F_ONE	PROC
ONE:
	invoke	printf, addr LEAD1
	invoke	scanf,addr format,addr IN_NAME
	invoke	printf, addr LEAD2
	invoke	scanf,addr format,addr IN_PWD
CHECK_NAME:	
	LEA	ESI,IN_NAME
	LEA	EDI,BNAME
LOPA1:	
	MOV	BL,[ESI]
	CMP	BL,[EDI]
	JNE	NAME_PWD_ERR
	INC	SI
	INC	DI
	DEC	AL
	CMP	AL,0
	JNE	LOPA1
	invoke	printf, addr CHECK
	JMP	CHECK_PWD	
CHECK_PWD:  
	LEA	ESI,IN_PWD
	LEA	EDI,BPASS
LOPA2:	
	MOV	BL,[ESI]
	CMP	BL,[EDI]
	JNE	ERR
	INC	SI
	INC	DI
	DEC	AL
	CMP	AL,0
	JNE	LOPA2	
	JMP	ONE_SUCCESS
ONE_SUCCESS:	
	MOV	AUTH,1
	invoke	printf, addr LEAD5
	JMP	RETURN_ONE
ERR:
	invoke	printf, addr LEAD3
	JMP	ONE
NAME_ENTER:	
	MOV	AUTH,0
	JMP	RETURN_ONE
RETURN_ONE:
	RET
F_ONE	ENDP

F_TWO	PROC
	invoke	printf, addr LEAD4
	invoke	scanf,addr format,addr GOOD_NAME
CHECK_GA1:
	MOV	AL,COUNTGA1
	LEA	ESI,GOOD_NAME
	LEA	EDI,GA1
LOPA3:	
	MOV	BL,[ESI]
	CMP	BL,[EDI]
	JNE	CHECK_GA2
	INC	ESI
	INC	EDI
	DEC	AL
	CMP	AL,0
	JNE	LOPA3
	JMP	RECORD_GA1
CHECK_GA2:
	MOV	AL,COUNTGA2
	LEA	ESI,GOOD_NAME
	LEA	EDI,GA2
LOPA4:	
	MOV	BL,[ESI]
	CMP	BL,[EDI]
	JNE	NOFIND_GOOD
	INC	ESI
	INC	EDI
	DEC	AL
	CMP	AL,0
	JNE	LOPA4
	JMP	RECORD_GA2
NOFIND_GOOD:  
	invoke	printf, addr LEAD6
	JMP RETURN_TWO
RECORD_GA1:
	LEA	ESI,GOOD
	LEA	EDI,GA1
	MOV	[ESI],EDI
	JMP	TWO_SUCCESS
RECORD_GA2:
	LEA	ESI,GOOD
	LEA	EDI,GA2
	MOV	[ESI],EDI
	JMP	TWO_SUCCESS
TWO_SUCCESS:
	invoke	printf, addr LEAD7
	JMP	RETURN_TWO
TWO_ERR:
	invoke	printf, addr LEAD8
	JMP	RETURN_TWO
RETURN_TWO:
	RET
F_TWO	ENDP

F_THREE  PROC
	LEA	ESI,GOOD
	MOV	EDI,[ESI]
	CMP	EDI,0
	JE	THREE_ERR
	MOV	GOOD,0
	MOV	BX,[EDI+15]
	MOV	AX,[EDI+17]
	SUB	BX,AX
	CMP	BX,0
	JE	THREE_ERR
	INC	AX
	MOV [EDI]+17,AX
	invoke	printf, addr LEAD10
	JMP	FOUR
THREE_ERR:
	invoke	printf, addr LEAD9
	JMP	RETURN_THREE
FOUR:
	MOV	CHEN,2
	LEA	DI,GA1
LOPA_FOUR:
	MOV	AX,0
	MOV	AX,WORD PTR [EDI]+11
	MOV	BX,1280
	IMUL	BX
	MOV	CX,WORD PTR [EDI]+13
	MOV	BX,0
	MOV	BL,BYTE PTR [EDI]+10
	IMUL	CX,BX
	DIV	CX
	MOV	SI,AX
	MOV	AX,WORD PTR [EDI]+17
	MOV	BX,64
	IMUL	BX
	DIV	WORD PTR [EDI]+15
	ADD	AX,SI
	MOV	[EDI]+19,AX
	DEC	CHEN
	CMP	CHEN,0
	JE	FOUR_SUCCESS
	LEA	EDI,GA2
	JMP	LOPA_FOUR
FOUR_SUCCESS:
	invoke	printf, addr LEAD11
	JMP RETURN_THREE
RETURN_THREE:
	RET
F_THREE  ENDP

F_FOUR PROC
	MOV	CHEN,2
	LEA	EDI,GA1
LOPA_FOUR:
	MOV	AX,0
	MOV	AX,WORD PTR [EDI]+11
	MOV	BX,1280
	IMUL	BX
	MOV	CX,WORD PTR [EDI]+13
	MOV	BX,0
	MOV	BL,BYTE PTR [EDI]+10
	IMUL	CX,BX
	DIV	CX
	MOV	SI,AX
	MOV	AX,WORD PTR [EDI]+17
	MOV	BX,64
	IMUL	BX
	DIV	WORD PTR [EDI]+15
	ADD	AX,SI
	MOV	[EDI]+19,AX
	DEC	CHEN
	CMP	CHEN,0
	JE	FOUR_SUCCESS
	LEA	DI,GA2
	JMP	LOPA_FOUR
FOUR_SUCCESS:
	invoke	printf, addr LEAD11
	JMP	RETURN_FOUR
RETURN_FOUR:
	RET
F_FOUR ENDP
	END